home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / windows / win31 / macsyma.arj / MACSDEMO.EXE / OPALG.OUT < prev    next >
Text File  |  1993-09-13  |  8KB  |  213 lines

  1.  
  2. (c1) /*             DEMONSTRATION OF THE OPERATOR ALGEBRA PACKAGE `OPALG'
  3.  
  4.    Copyright (c) 1988, 1987, 1986 Symbolics, Inc. 
  5.    Portions copyright (c) 1986, 1985 GTE Laboratories Incorporated.
  6. */
  7. if get('opalg,'version) = false then load(opalg)$
  8. C:\MACSD2B\share\OPALG.fas being loaded.
  9.  
  10. (c2) /* Make sure USE_OPERATORS is turned on. */
  11. use_operators:true$
  12.  
  13. (c3) /*
  14.                  BASIC OPERATIONS ON OPERATORS
  15. */
  16. /* Addition of operators */
  17. (u + v + w)(x);
  18. |$label(0,15,Times New Roman,$(d3$))w$paren(x)$hinge()$in( + )v$paren(x)$hinge()$in( + )u$paren(x)
  19.  
  20. (c4) /* Composition of operators */
  21. (u . v . w)(x);
  22. |$label(0,15,Times New Roman,$(d4$))u$paren(v$paren(w$paren(x)))
  23.  
  24. (c5) /* Scalar multiplication of a operator by a scalar */
  25. (2 * u)(x);
  26. |$label(0,15,Times New Roman,$(d5$))2$hinge()$in( )u$paren(x)
  27.  
  28. (c6) (u^^3)(x);
  29. |$label(0,15,Times New Roman,$(d6$))u$paren(u$paren(u$paren(x)))
  30.  
  31. (c7) declare(c,opscalar)$
  32.  
  33. (c8) (u + c)(x);
  34. |$label(0,15,Times New Roman,$(d8$))u$paren(x)$hinge()$in( + )c$in( )x
  35.  
  36. (c9) (c^2 * u)(x);
  37. |$label(0,15,Times New Roman,$(d9$))$sup(c,2)$hinge()$in( )u$paren(x)
  38.  
  39. (c10) /* 1 serves as the identity operator here. */
  40. 1(x);
  41. |$label(0,15,Times New Roman,$(d10$))x
  42.  
  43. (c11) /* Operators applied to more than one argument */
  44. (u + v + w)(x, y);
  45. |$label(0,15,Times New Roman,$(d11$))w$paren(x$ina($, )$hinge()y)$hinge()$in( + )v$paren(x$ina($, )$hinge()y)$hinge()$in( + )u$paren(x$ina($, )$hinge()y)
  46.  
  47. (c12) (u . v . w)(x, y);
  48. |$label(0,15,Times New Roman,$(d12$))u$paren(v$paren(w$paren(x$ina($, )y)))
  49.  
  50. (c13) /* The following operations on operators are left undefined */
  51. (u * v)(x);
  52. |$label(0,15,Times New Roman,$(d13$))u$in( )v$paren(x)
  53.  
  54. (c14) (u^2)(x);
  55. |$label(0,15,Times New Roman,$(d14$))$sup(u,2)$paren(x)
  56.  
  57. (c15) /* The Differentiation Operator DIFFOP */
  58. diffop(x,2) + diffop(x);
  59. |$label(0,15,Times New Roman,$(d15$))$q($sup(d,2),d$sup(x,2))$hinge()$in( + )$q(d,dx)
  60.  
  61. (c16) %(x^5);
  62. |$label(0,15,Times New Roman,$(d16$))5$in( )$sup(x,4)$hinge()$in( + )20$in( )$sup(x,3)
  63.  
  64. (c17) diffop(x,1,y,2);
  65. |$label(0,15,Times New Roman,$(d17$))$q($sup(d,3),dx d$sup(y,2))
  66.  
  67. (c18) /* The Integration Operator INTEGOP */
  68. integop(x)^^2 + integop(x);
  69. |$label(0,15,Times New Roman,$(d18$))$sup($paren($integrate(,x,,),$(,$)),$paren(2,<,>))$hinge()$in( + )$integrate(,x,,)
  70.  
  71. (c19) %(x^5);
  72. |$label(0,15,Times New Roman,$(d19$))$q($sup(x,7),42)$hinge()$in( + )$q($sup(x,6),6)$hinge()$in( + )%integconst2$in( )x$hinge()$in( + )%integconst3$hinge()$in( + )%integconst1
  73.  
  74. (c20) /* Definite integration */
  75. integop(x,2,4);
  76. |$label(0,15,Times New Roman,$(d20$))$integrate(,x,2,4)
  77.  
  78. (c21) %(x^2);
  79. |$label(0,15,Times New Roman,$(d21$))$q(56,3)
  80.  
  81. (c22) /* The Constant Operator CONSTOP */
  82. constop(a);
  83. |$label(0,15,Times New Roman,$(d22$))$sub(C,<a>)
  84.  
  85. (c23) %(x,y,z);
  86. |$label(0,15,Times New Roman,$(d23$))a
  87.  
  88. (c24) diffop(x) . integop(x);
  89. |$label(0,15,Times New Roman,$(d24$))1
  90.  
  91. (c25) %(x^2);
  92. |$label(0,15,Times New Roman,$(d25$))$sup(x,2)
  93.  
  94. (c26) integop(x) . diffop(x);
  95. |$label(0,15,Times New Roman,$(d26$))$sub(C,<%integconst4>)$hinge()$in( + )1
  96.  
  97. (c27) %(x^2);
  98. |$label(0,15,Times New Roman,$(d27$))$sup(x,2)$hinge()$in( + )%integconst4
  99.  
  100. (c28) /*
  101.                        SAMPLE MANIPULATIONS
  102. */
  103. diffop(x,2) + diffop(x);
  104. |$label(0,15,Times New Roman,$(d28$))$q($sup(d,2),d$sup(x,2))$hinge()$in( + )$q(d,dx)
  105.  
  106. (c29) op1: multthru(diffop(x,3) . %);
  107. |$label(0,15,Times New Roman,$(d29$))$q($sup(d,5),d$sup(x,5))$hinge()$in( + )$q($sup(d,4),d$sup(x,4))
  108.  
  109. (c30) %(x^10);
  110. |$label(0,15,Times New Roman,$(d30$))5040$in( )$sup(x,6)$hinge()$in( + )30240$in( )$sup(x,5)
  111.  
  112. (c31) integop(x);
  113. |$label(0,15,Times New Roman,$(d31$))$integrate(,x,,)
  114.  
  115. (c32) op2: 2 * % + op1;
  116. |$label(0,15,Times New Roman,$(d32$))$q($sup(d,5),d$sup(x,5))$hinge()$in( + )$q($sup(d,4),d$sup(x,4))$hinge()$in( + )2$in( )$integrate(,x,,)
  117.  
  118. (c33) %(x^5);
  119. |$label(0,15,Times New Roman,$(d33$))2$in( )$paren($q($sup(x,6),6)$in( + )%integconst5,$(,$))$hinge()$in( + )120$in( )x$hinge()$in( + )120
  120.  
  121. (c34) multthru(diffop(x) . op2);
  122. |$label(0,15,Times New Roman,$(d34$))$q($sup(d,6),d$sup(x,6))$hinge()$in( + )$q($sup(d,5),d$sup(x,5))$hinge()$in( + )2
  123.  
  124. (c35) op2^^2;
  125. |$label(0,15,Times New Roman,$(d35$))$sup($open($()$q($sup(d,5),d$sup(x,5))$hinge()$in( + )$q($sup(d,4),d$sup(x,4))$hinge()$in( + )2$in( )$integrate(,x,,)$close($)),$paren(2,<,>))
  126.  
  127. (c36) expand(%);
  128. |$label(0,15,Times New Roman,$(d36$))4$in( )$sup($paren($integrate(,x,,),$(,$)),$paren(2,<,>))$hinge()$in( + )$q($sup(d,10),d$sup(x,10))$hinge()$in( + )2$in( )$q($sup(d,9),d$sup(x,9))$hinge()$in( + )$q($sup(d,8),d$sup(x,8))$hinge()$in( + )4$in( )$q($sup(d,4),d$sup(x,4))$hinge()$in( + )4$in( )$q($sup(d,3),d$sup(x,3))$hinge()$in( + )2$in( )$sub(C,<%integconst7>)$hinge()$in( + )2$in( )$sub(C,<%integconst6>)
  129.  
  130. (c37) op3: a . diffop(x,2);
  131. |$label(0,15,Times New Roman,$(d37$))a$hinge()$in( . )$q($sup(d,2),d$sup(x,2))
  132.  
  133. (c38) %(x^5);
  134. |$label(0,15,Times New Roman,$(d38$))a$paren(20$in( )$sup(x,3))
  135.  
  136. (c39) declare(a,opscalar)$
  137.  
  138. (c40) op3(x^5);
  139. |$label(0,15,Times New Roman,$(d40$))20$hinge()$in( )a$hinge()$in( )$sup(x,3)
  140.  
  141. (c41) /*
  142.               A SAMPLING OF BUILT-IN SIMPLIFICATIONS
  143. */
  144. diffop(x,1,y,0,z,2);
  145. |$label(0,15,Times New Roman,$(d41$))$q($sup(d,3),dx d$sup(z,2))
  146.  
  147. (c42) diffop(x,0);
  148. |$label(0,15,Times New Roman,$(d42$))1
  149.  
  150. (c43) diffop(x,i) . diffop(y,j) . diffop(x,k);
  151. |$label(0,15,Times New Roman,$(d43$))$q($sup(d,k$in( + )j$in( + )i),d$sup(x,k$in( + )i) d$sup(y,j))
  152.  
  153. (c44) diffop(x,m,y,n)^^i;
  154. |$label(0,15,Times New Roman,$(d44$))$q($sup(d,i$in( )n$in( + )i$in( )m),d$sup(x,i$in( )m) d$sup(y,i$in( )n))
  155.  
  156. (c45) diffop(x,i) . integop(x);
  157. |$label(0,15,Times New Roman,$(d45$))$q($sup(d,i$in( - )1),d$sup(x,i$in( - )1))
  158.  
  159. (c46) integop(x) . diffop(x,i);
  160. |$label(0,15,Times New Roman,$(d46$))$q($sup(d,i$in( - )1),d$sup(x,i$in( - )1))$hinge()$in( + )$sub(C,<%integconst8>)
  161.  
  162. (c47) diffop(x,-3);
  163. |$label(0,15,Times New Roman,$(d47$))$sup($paren($integrate(,x,,),$(,$)),$paren(3,<,>))
  164.  
  165. (c48) constop(c) . anything;
  166. |$label(0,15,Times New Roman,$(d48$))$sub(C,<c>)
  167.  
  168. (c49) constop(c)^^2;
  169. |$label(0,15,Times New Roman,$(d49$))$sub(C,<c>)
  170.  
  171. (c50) /*
  172.                          AN EXTENDED EXAMPLE
  173. */
  174. /* Test that two operator expressions give the same results. */
  175. declare(f,opscalarfun)$
  176.  
  177. (c51) op4: diffop(x) . f(x);
  178. |$label(0,15,Times New Roman,$(d51$))$q(d,dx)$hinge()$in( . )f$paren(x)
  179.  
  180. (c52) /* Note the new partial differentiation representation in the following. */
  181. op5: f(x) . diffop(x) + diff(f(x),x);
  182. |$label(0,15,Times New Roman,$(d52$))f$paren(x)$in( . )$q(d,dx)$hinge()$in( + )$sup(f,$paren(1))$paren(x)
  183.  
  184. (c53) res1: op4(sin(x));
  185. |$label(0,15,Times New Roman,$(d53$))$sup(f,$paren(1))$paren(x)$in( )sin$paren(x)$hinge()$in( + )f$paren(x)$in( )cos$paren(x)
  186.  
  187. (c54) res2: op5(sin(x));
  188. |$label(0,15,Times New Roman,$(d54$))$sup(f,$paren(1))$paren(x)$in( )sin$paren(x)$hinge()$in( + )f$paren(x)$in( )cos$paren(x)
  189.  
  190. (c55) /* Generate a rule */
  191. matchdeclare(s,opscalarp,y,true)$
  192.  
  193. (c56) tellsimpafter(diffop(y) . s, s . diffop(y) + diff(s,y))$
  194.  
  195. (c57) declare(x,opscalar,n,integer)$
  196.  
  197. (c58) diffop(x) . x^n;
  198. |$label(0,15,Times New Roman,$(d58$))$sup(x,n)$in( . )$q(d,dx)$hinge()$in( + )n$in( )$sup(x,n$in( - )1)
  199.  
  200. (c59) %(sin(x));
  201. |$label(0,15,Times New Roman,$(d59$))n$in( )$sup(x,n$in( - )1)$in( )sin$paren(x)$hinge()$in( + )$sup(x,n)$in( )cos$paren(x)
  202.  
  203. (c60) res1, f(x) := x^n;
  204. |$label(0,15,Times New Roman,$(d60$))n$in( )$sup(x,n$in( - )1)$in( )sin$paren(x)$hinge()$in( + )$sup(x,n)$in( )cos$paren(x)
  205.  
  206. (c61) /* To clean up if so desired, type (some subset of) the following: 
  207. remove([c,a,x],opscalar,n,integer,f,opscalarfun,[s,y],matchdeclare,
  208.        [op1,op2,op3,op4,op5,res1,res2],value);
  209. reset(integconstnum)$
  210. remrule(".",all)$
  211. More precisely, remove the most recent rule assigned to the operator "." .
  212. */
  213.